package tech.nuoson.wisdom.domain.speechtrans;

import lombok.Getter;

@Getter
public class SpeechTransStateMessage extends AbstractSpeechTransMessage<SpeechTransStateMessage.State> {

    // #region -- ** 构造函数 **

    public SpeechTransStateMessage(State state) {
        super(AbstractSpeechTransMessage.MessageType.STATE, state);
    }
    // #endregion

    // #region -- ** 公共方法 **

    /**
     * 
     * @return
     */
    public static SpeechTransStateMessage of(StateCode code) {
        return SpeechTransStateMessage.of(code, null);
    }

    /**
     * 
     * @return
     */
    public static SpeechTransStateMessage of(StateCode code, String message) {
        return new SpeechTransStateMessage(new SpeechTransStateMessage.State(code, message));
    }

    // #endregion

    // #region -- ** 内部类 **

    @Getter
    public static class State {
        private StateCode code;
        private String message;

        public State(StateCode code, String message) {
            this.code = code;
            this.message = message;
        }
    }

    public static enum StateCode {
        // websocket 连接成功
        SESSION_CONNECTED(0),
        // websocket 连接断开
        SESSION_DISCONNECTED(1),
        // websocket 连接异常
        SESSION_ERROR(2),
        ;

        private int value;

        StateCode(int value) {
            this.value = value;

        }

        public int getValue() {
            return this.value;
        }

    }
    // #endregion

}
